/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.cemaden.library.model.smp;

import br.gov.cemaden.library.model.BaseEntity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.codehaus.jackson.annotate.JsonBackReference;

/**
 *
 * @author paulo.dias
 */
@Entity
@Table(name = "smp_cpu", schema = "smp")
@SequenceGenerator(name = "sequence", sequenceName = "smp.smp_cpu_sequence", schema = "smp")
@NamedQueries({
    @NamedQuery(name = "CPU.findAll", query = "SELECT a FROM CPU a ORDER BY a.id ASC"),
    @NamedQuery(name = "CPU.findById", query = "SELECT a FROM CPU a WHERE a.id = :id"),
    @NamedQuery(name = "CPU.findByTotalSystemTime", query = "SELECT a FROM CPU a WHERE a.totalSystemTime = :totalSystemTime"),
    @NamedQuery(name = "CPU.findByCacheSize", query = "SELECT a FROM CPU a WHERE a.cacheSize = :cacheSize"),
    @NamedQuery(name = "CPU.findByCorPerSockets", query = "SELECT a FROM CPU a WHERE a.corPerSockets = :corPerSockets"),
    @NamedQuery(name = "CPU.findByModel", query = "SELECT a FROM CPU a WHERE a.model = :model"),
    @NamedQuery(name = "CPU.findByTotalCores", query = "SELECT a FROM CPU a WHERE a.totalCores = :totalCores"),
    @NamedQuery(name = "CPU.findByTotalSockets", query = "SELECT a FROM CPU a WHERE a.totalSockets = :totalSockets"),
    @NamedQuery(name = "CPU.findByVendor", query = "SELECT a FROM CPU a WHERE a.vendor = :vendor"),
    @NamedQuery(name = "CPU.findByCpuUsage", query = "SELECT a FROM CPU a WHERE a.cpuUsage = :cpuUsage"),
    @NamedQuery(name = "CPU.findByExecHardware", query = "SELECT a FROM CPU a WHERE a.execHardware = :execHardware"),})
public class CPU implements Serializable, BaseEntity {

    @Id
    @GeneratedValue(generator = "sequence", strategy = GenerationType.AUTO)
    @Column(name = "id_cpu", nullable = false, unique = true)
    private Long id;
    
    @Column(name = "total_system_time")
    private String totalSystemTime;
    
    @Column(name = "cache_size")
    private Double cacheSize;
    
    @Column(name = "cor_per_sockets")
    private Integer corPerSockets;
    
    @Column(name = "model")
    private String model;
    
    @Column(name = "total_cores")
    private Integer totalCores;
    
    @Column(name = "total_sockets")
    private Integer totalSockets;
    
    @Column(name = "vendor")
    private String vendor;
    
    @Column (name = "CPU_Usage")
    private Double cpuUsage;
    
    @OneToOne
    @JsonBackReference
    @JoinColumn(name = "id_exec_hardware", referencedColumnName = "id_exec_hardware", unique = true)
    private ExecHardware execHardware;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTotalSystemTime() {
        return totalSystemTime;
    }

    public void setTotalSystemTime(String totalSystemTime) {
        this.totalSystemTime = totalSystemTime;
    }

    public Double getCacheSize() {
        return cacheSize;
    }

    public void setCacheSize(Double cacheSize) {
        this.cacheSize = cacheSize;
    }

    public Integer getCorPerSockets() {
        return corPerSockets;
    }

    public void setCorPerSockets(Integer corPerSockets) {
        this.corPerSockets = corPerSockets;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public Integer getTotalCores() {
        return totalCores;
    }

    public void setTotalCores(Integer totalCores) {
        this.totalCores = totalCores;
    }

    public Integer getTotalSockets() {
        return totalSockets;
    }

    public void setTotalSockets(Integer totalSockets) {
        this.totalSockets = totalSockets;
    }

    public String getVendor() {
        return vendor;
    }

    public void setVendor(String vendor) {
        this.vendor = vendor;
    }

    public ExecHardware getExecHardware() {
        return execHardware;
    }

    public void setExecHardware(ExecHardware execHardware) {
        this.execHardware = execHardware;
    }

    public Double getCpuUsage() {
        return cpuUsage;
    }

    public void setCpuUsage(Double cpuUsage) {
        this.cpuUsage = cpuUsage;
    }
   

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CPU other = (CPU) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "CPU{" + "id=" + id + ", totalSystemTime=" + totalSystemTime + ", cacheSize=" + cacheSize + ", corPerSockets=" + corPerSockets + ", model=" + model + ", totalCores=" + totalCores + ", totalSockets=" + totalSockets + ", vendor=" + vendor + ", cpuUsage=" + cpuUsage + ", execHardware=" + execHardware + '}';
    }

}
